<?php

namespace common\jobs;

use Yii;
use common\jobs\base\BaseJob;
use common\jobs\handle\ShopOrderHandle;

/**
 * 订单自动过期处理
 * Class ShopOrderExpiredJob.
 */
class ShopOrderExpiredJob extends BaseJob {

    public $order_id = null;

    /**
     * @inheritdoc
     */
    public function execute($queue) {
        if ($this->order_id == null) {
            throw new Exception('order_id is null!');
        }
        $status = ShopOrderHandle::cancelExpired($this->order_id, $msg);
        if (!$status) {
            Yii::error([
                'order_id' => $this->order_id,
                'msg' => $msg,
            ], __METHOD__);
            return $this->dumpError('[ORDERID:' . $this->order_id . ']' . $msg);
        }
        return true;
    }

}
